class Solution(object):
    def rotateTheBox(self, box):
        m = len(box)
        n = len(box[0])
        out = [['.' for _ in range(m)] for _ in range(n)]
        for i in range(m):
            base_index = n - 1
            for j in range(n - 1, -1, -1):
                if box[i][j] == '*':
                    base_index = j - 1
                    out[j][m - 1 - i] = '*'
                else:
                    if box[i][j] == '#':
                        out[base_index][m - 1 - i] = '#'
                        base_index -= 1
        return out


